# Maintainer: Antonio Rojas <arojas@archlinux.org>

pkgbase=kquickimageeditor
pkgname=(kquickimageeditor5
         kquickimageeditor)
pkgver=0.3.0
pkgrel=2
pkgdesc='QML image editing components'
license=(LGPL)
arch=(loong64 x86_64)
url='https://invent.kde.org/libraries/kquickimageeditor'
depends=(gcc-libs
         glibc)
makedepends=(extra-cmake-modules
             qt5-base
             qt5-declarative
             qt6-base
             qt6-declarative)
source=(https://download.kde.org/stable/$pkgbase/$pkgbase-$pkgver.tar.xz{,.sig})
sha256sums=('330ebf3653883eeebde54385d783c51c2d30ff77d41b294ece79af7e9c21c6f8'
            'SKIP')
validpgpkeys=(39FFA93CAE9C6AFC212AD00202325448204E452A) # Carl Schwan <carl@carlschwan.eu>

build() {
  cmake -B build5 -S $pkgbase-$pkgver
  cmake --build build5

  cmake -B build -S $pkgbase-$pkgver \
    -DQT_MAJOR_VERSION=6
  cmake --build build
}

package_kquickimageeditor5() {
  depends+=(qt5-base
            qt5-declarative)
  conflicts=('kquickimageeditor<0.3.0-2')
  replaces=('kquickimageeditor<0.3.0-2')

  DESTDIR="$pkgdir" cmake --install build5
# fix conflicts with Qt6 version
  mv "$pkgdir"/usr/lib/cmake/KQuickImageEditor{,5}
}

package_kquickimageeditor() {
  depends+=(qt6-base
            qt6-declarative)

  DESTDIR="$pkgdir" cmake --install build
}
